<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../static/css/login.css">
    <script src="../static/js/jquery-1.7.2.min.js"></script>
    <script src="../static/js/register.js"></script>
    <title>树懒电影登录</title>
    <script >
    </script>
</head>
<body>
    <div id="container">
        <div id="container-child">
            <div id="img-div"><img src="../static/img/shulan.png"></div>
            <div id="login-div">
                <div>
                    <p class="p-title">登录您的树懒电影</p>
                    <form id="login-form" method="post">
                        <div class="input-d">
                            <input class="input-text" type="text" name="userphone" id="userphone" placeholder="请输入您的账号">
                        </div>
                        <div class="input-d">
                            <input class="input-text" type="password" name="password" id="password" placeholder="请输入您的密码">
                        </div>
                        <div class="div-input">
                            <div>
                                <input type="checkbox" value=“1” class=“remeber” onclick="onClickHander(this)">
                                <label>记住密码</label>
                            </div>
                        </div> 
                        <button type="button" class="login-button" onclick="login_()">登&emsp;录</button>
                        <div class="footer"> <a href="http://127.0.0.1:5000/regis">注册</a> | <a href="http://127.0.0.1:5000/reset">忘记密码</a></div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    var cb=0
    function onClickHander(obj) {
        if(obj.checked==true){
            cb=1
            // alert(cb)
        }else{
            cb=0
            // alert(cb)
        }
    }
    function login_(){
        var userphone=document.getElementById("userphone").value
        var password=document.getElementById("password").value
        // alert(cb)
        $.ajax({
                url: "/web_login",
                data: {
                    userphone:userphone,password:password,cb:cb
                },
                success: function (data) {
                    //正常验证失败弹窗
                    if (data.data == 0)
                        alert("账号或密码错误！")
                    //验证成功，返回response
                    if (data.data != 0)
                        window.open("http://127.0.0.1:5000/show","_self")
                },
                error: function (xhr, type, errorThrown) {
                    print("登录js，验证账号密码ajax请求失败！")
                }
        })
    }
</script>